﻿using System;
using System.Web.UI;
using Model.Contratos;
using System.Web.UI.WebControls;
using Services.Refeicoes;
using Model.Refeicoes;

namespace welwitschia.ServicoRefeicoes
{
    public partial class RefeicoesAbertasContratos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lvContratos.DataSource = RefeicaoService.ObterListaUnidadesComRefeicoesEstadoRec();
                lvContratos.DataBind();
            }
        }

        protected void lvContratos_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
        }

        protected void lvContratos_ItemEditing(object sender, ListViewEditEventArgs e)
        {
        }

        protected void lvContratos_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                String[] commandArgs = e.CommandArgument.ToString().Split(';');
                String url = String.Format("~\\ServicoRefeicoes\\RefeicoesServidas.aspx?uid={0}&dt={1}", 
                    commandArgs[0], Convert.ToDateTime(commandArgs[1]).ToString("yyyyMMdd"));

                Response.Redirect(url);
            }
        }


    }
}